\documentclass[12pt]{article}
\usepackage{amsmath,amsthm}
\usepackage{times}
\usepackage{verbatim}
\begin{document}

\section*{Assignment 1}
\subsection*{Description}
\paragraph{}
Write a program to interface with and track the train, displaying relevant
information on the terminal. Concurrently, the program must monitor a
wall-time timer with time lags no greater than 1/20 second while not losing
time.

\subsection*{The Box}
\paragraph{}
Your code will run on the following environment:
\begin{itemize}
\item 2 COM ports (COM1, COM2)
  \begin{itemize}
  \item COM1 - train
  \item COM2 - thin-client terminal
  \end{itemize}
\item ARM processor + 32 MB RAM + 4 MB flash RAM + peripherals
\end{itemize}

\paragraph{}
Normally, your program runs on the same machine it was compiled on. In this
course, it will not - so we need a cross-compiler. A cross-compiler runs on
one architecture but emits instructions for another architecture. We must
load the program onto the chip and set the instruction register to the correct
location to execute the program. The software responsible for this is called
a boot loader (e.g. GRUB, LILO, etc.)

\paragraph{}
More detailed: the cross-compiler runs on Linux machines in CSCF environment -
linux.student.cs. You must login to these machines, as the undergrad
environment is typically Solaris. Then you must set \$PATH to pick up the
compiler (in ~wmcowan - GNU toolchain, consisting of a compiler, an
assembler, a link editor, and an archive utility, resides here.) You will also
find there a Makefile and a link loader orex.ld.

\paragraph{}
You should try

\begin{verbatim}
ld --version
\end{verbatim}

which outputs a load of crap - which is why orex.ld is preferable. (Of course,
it is also highly specific.)

\paragraph{}
We send programs to The Box via TFTP (Trivial File Transfer Protocol):

\begin{verbatim}
cp <your_program> /u/cs452/tftpboot/ARM
\end{verbatim}

You then boot the program from RedBoot, using the terminal in the train room.
RedBoot will offer you the option to load an ELF executable via TFTP into a
specific memory location:

\begin{verbatim}
load -b <mem_addr> -h <tftp_server_ip> <name>
\end{verbatim}

You can then execute your program:

\begin{verbatim}
go [<mem_addr>]
\end{verbatim}

RedBoot also allows you the opportunity to inspect The Box's memory.
All I/O is memory-bound; devices are mapped to specific addresses in memory.
As such, you can directly manipulate devices from RedBoot.

\paragraph{}
If your program terminates normally, it will return to the RedBoot screen.
Otherwise, you may have to reset The Box.

\subsection{Busy-Wait I/O}
\paragraph{}
You will find a header file \verb=bwio.h= and associated library \verb=bwio.a=
on the system. \verb=bwio.h= declares and defines a number of UNIX-style
utilities for I/O such as \verb=getc()=, \verb=putc()=, and \verb=printf()=.

\paragraph{}
The Box sets a ready bit when it is ready to perform terminal I/O. The
\verb=bwio.h= library busy-waits until the bit is set. In fact, The Box has
two ready bits: one for receive, one for transmit. I/O is performed using the
RS-232 protocol.

\paragraph{}
As a final note, busy-wait I/O is incredibly robust due to its simplicity.

\subsection{Other Useful Things}
You will find the following useful:

\begin{itemize}
\item \verb=bwio.h=: described above.
\item \verb=ts7200.h=: contains register locations, important bitmasks, etc.
\end{itemize}

\paragraph{}
The Box has a real-time clock; you will NOT use that, as it has very coarse
resolution. Instead, there are two countdown timers within The Box. You write
a value to the timer by writing to their data register. The timers then count
down from that value repeatedly, setting a timer ready bit each time they
reach 0. Your program MUST read the ready bit more often than it is set.

\end{document}
